package com.day9;

import java.util.Comparator;
import java.util.TreeMap;

public class Maymap1 {
    public static void main(String[] args) {
        Comparator<Student2> cc = new Comparator<Student2>() {
            @Override
            public int compare(Student2 o1, Student2 o2) {
                int a = o1.getAge() - o2.getAge();
                a = a == 0 ? o1.getName().compareTo(o2.getName()) : a;
                return a;
            }
        };
        TreeMap<Student2, String> tm = new TreeMap<>(cc);
        Student2 sd1 = new Student2("zhangsan", 23);
        Student2 sd2 = new Student2("lisi", 22);
        Student2 sd3 = new Student2("wangwu", 23);
        tm.put(sd1, "浙江");
        tm.put(sd2, "邵阳");
        tm.put(sd3, "湖南");
        tm.forEach((Student2 key, String value) -> {
            System.out.println(key + ":" + value);
        });
    }
}
